﻿module Settings
    open System.IO
    open System.Linq

    type SettingKey =
        | UserName
        | PassWord
        //| TargetURI
        | GenresToExlude
        | AllowedHosts
        | IncludeVariusArtist
        | IncludeRips
        | NotFound
    let GetSettings settingsFilePath =
        seq {
            let rows = File.ReadAllLines(settingsFilePath)
            for r in rows do
                let arr = r.Split('=')
                let name = arr.First().ToLower().Trim()
                let value = arr.Last().Trim()
                yield match name with
                    | "username" -> ( SettingKey.UserName, value)
                    | "password" -> ( SettingKey.PassWord, value)
                    //| "targeturi" -> ( SettingKey.TargetURI, value)
                    | "genrestoexlude" -> ( SettingKey.GenresToExlude, value)
                    | "allowedhosts" -> ( SettingKey.AllowedHosts, value)
                    | "includevariusartist" -> ( SettingKey.IncludeVariusArtist, value)
                    | "includerips" -> ( SettingKey.IncludeRips, value)
                    | _ -> ( SettingKey.NotFound, value)
        }

    let GetValue settingsSeq key =
        snd (settingsSeq |> Seq.find(fun (k, v) -> k = key))

